package com.dzt.androidframework.view;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.dzt.androidframework.R;
import com.dzt.androidframework.activity.ActivityTitle;
import com.dzt.androidframework.adapter.FunctionAdapter;

import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.List;

public class ViewActivity extends ActivityTitle {

	@ViewInject(R.id.lv_main)
	private ListView lvMain;
	private FunctionAdapter functionAdapter;
	private List<String> mainList = new ArrayList<>();

	@Override
	protected int getLayoutId() {
		return R.layout.activity_view;
	}

	@Override
	protected void initParams() {
		setTitleView(R.string.menu_11);
		String[] menus = getResources().getStringArray(R.array.view_menus);
		for (String menu : menus) {
			mainList.add(menu);
		}
		functionAdapter = new FunctionAdapter(this, mainList);
		lvMain.setAdapter(functionAdapter);
		lvMain.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
				mainListItemClick(i);
			}
		});
	}

	@Override
	protected void initData(Bundle savedInstanceState) {

	}

	private void mainListItemClick(int i) {
		switch (i) {
			case 0:
				startActivity(BookPageActivity.class, null);
				break;
			case 1:
				startActivity(CircleBarActivity.class, null);
				break;
			case 2:
				startActivity(ExpandMenuActivity.class, null);
				break;
			case 3:
				startActivity(ClockActivity.class, null);
				break;
			case 4:
				startActivity(CityPickerActivity.class, null);
				break;
			default:
				break;
		}
	}

	@Override
	protected String[] initPermissions() {
		return new String[0];
	}
}
